package demo1;

import java.security.Key;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 沈明月
 * Date: 2023-01-01
 * Time: 18:34
 */
public class Computer {
    public void open(){
        System.out.println("开机！");
    }
    public void close(){
        System.out.println("关机！");
    }

    public void useDevice(IUSB usb){
        usb.openDevice();
        if(usb instanceof Mouse){
            Mouse mouse = (Mouse)usb;
            mouse.click();
        }else if(usb instanceof KeyBoard){
            KeyBoard keyBoard = (KeyBoard) usb;
            keyBoard.inPut();
        }
        usb.closeDevice();
    }
}
